package cn.terminus.data.customer.customreceive.impl;

import cn.terminus.common.customer.bean.customreceive.dto.*;
import cn.terminus.data.customer.customreceive.dao.CustomReceiveDao;
import cn.terminus.data.customer.customreceive.mapper.CustomReceiveMapper;
import cn.terminus.result.common.page.TerminusPageAble;
import cn.terminus.result.common.page.TerminusPageInfo;
import cn.terminus.result.common.util.BeanCopyUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CustomReceive)表服务实现类
 *
 * @author makejava
 * @since 2021-08-12 10:27:51
 */
@Repository
public class CustomReceiveDaoImpl implements CustomReceiveDao {
    @Resource
    private CustomReceiveMapper customReceiveMapper;

    @Override
    public Integer add(CustomReceiveNewDto dto) {
        return customReceiveMapper.add(dto);
    }

    @Override
    public Integer update(CustomReceiveEditDto dto) {
        return customReceiveMapper.update(dto);
    }

    @Override
    public List<CustomReceiveResultDto> gets(CustomReceiveGetsDto dto) {
        return customReceiveMapper.gets(dto);
    }

    @Override
    public List<CustomReceiveResultDto> query(CustomReceiveQueryDto dto) {
        return customReceiveMapper.query(dto);
    }

    @Override
    public Integer delete(CustomReceiveDeleteDto dto) {
        return customReceiveMapper.delete(dto);
    }

    @Override
    public TerminusPageAble<CustomReceiveResultDto> page(CustomReceiveQueryDto dto, TerminusPageInfo page) {
        PageHelper.startPage(page.getCurrentPage(), page.getPageSize());
        Page<CustomReceiveResultDto> result = (Page<CustomReceiveResultDto>) customReceiveMapper.query(dto);
        return new TerminusPageAble<>(BeanCopyUtils.copy(result.getResult(), CustomReceiveResultDto.class), page, result.getTotal());
    }

    @Override
    public List<CustomReceiveResultDto> queryPage(CustomPageQueryDto dto) {
        return customReceiveMapper.queryPage(dto);
    }

    @Override
    public Integer batchConfig(BatchConfigDto configDto) {
        return customReceiveMapper.batchConfig(configDto);
    }

    @Override
    public Integer insertBatch(List<CustomReceiveNewDto> receiveNewDtoList) {
        return customReceiveMapper.insertBatch(receiveNewDtoList);

    }
}
